package com.collection.linkedlist;

import java.util.LinkedList;

public class LinkedListInsertElementExample {
	public static void main(String[] args) {
		 
	    //create LinkedList object
	    LinkedList lList = new LinkedList();
	   
	    //add elements to LinkedList
	    lList.add("1");
	    lList.add("2");
	    lList.add("3");
	    lList.add("4");
	    lList.add("5");
	   
	    System.out.println("LinkedList contains : " + lList);
	   
	    /*
	     * To insert an element into LinkedList object, use
	     * void add(int index , Object element) method.
	     *
	     * It inserts specified element at specified index in the LinkedList by
	     * shifting current elements and subsequent elements to the right.
	     */
	   
	     lList.add(2, "2.5");
	     System.out.println("After inserting 2.5, LinkedList contains : " + lList);
	   
	   
	  }
}
